package modelo.armas;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

import com.thoughtworks.xstream.XStream;

import modelo.Movil;
import modelo.naves.NaveAlgo42;
import modelo.naves.NavesAutonomas;

public class BalasAlgo42 extends Balas{
	
	public BalasAlgo42 (int danio, int alcance){
		super(danio, alcance);
	}
	
	public void chocarCon (Movil movil){
		if (this.chocaCon(movil)){
			movil.chocarConBalaAlgo42(this);
		}
	}
	
	/*
	 * las balas del algo 42 no lo afectan
	 */
	public void chocarConAlgo42(NaveAlgo42 algo42){
		//nada
	}
	
	/*
	 * las balas no se chocan entre si  
	 */
	public void chocarConBalaAlgo42 (BalasAlgo42 unaBala){
		//nada
	}
	
	/*
	 * las balas no se chocan entre si
	 */
	public void chocarConBalaEnemiga (BalasEnemigas unaBala){
		//nada
	}
	
	/*
	 * las balas del algo 42 deben atacar a las naves autonomas
	 */
	public void chocarConNaveAutonoma (NavesAutonomas unaNave){
		chocarConNave (unaNave);
	}

	public void chocarConRadarEnemigo(RadarEnemigo unRadar) {
		// nada
	}
	
	public void chocarConRadarAlgo42 (RadarAlgo42 unRadar) {
		// nada
	}
	
	public void persistir(String file) throws IOException{
		XStream xstream = new XStream();
		xstream.alias("BalasAlgo42", BalasAlgo42.class);
		FileWriter xmlFile = new FileWriter(file);
		xstream.toXML(this,xmlFile);
	}
	
	public BalasAlgo42(String file) throws IOException{
		XStream xstream = new XStream();
		BalasAlgo42 objAux;
		xstream.alias("BalasAlgo42", BalasAlgo42.class);
		objAux = (BalasAlgo42)xstream.fromXML(new FileReader(file));
		this.danio = objAux.danio;
		this.alcance = objAux.alcance ;
		this.estado = objAux.estado;
		
	}
	
	
	
}
